home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Utilities / Programming / EnterAct 3.5 / Drag_on Modules / hAWK programs / $Lockout < prev    next >
Encoding:
Text File  |  1993-04-09  |  8.9 KB  |  279 lines  |  [TEXT/KEEN]

  1. #$Lockout: WARNING LOOKOUT OH GOSH
  2. #This program can only be terminated with
  3. #<Command><period> when it is set for message display. If you forget that, you’ll
  4. #have to do something considerably more drastic to get it to stop.
  5.  
  6. #Usage: none that’s defendable.
  7. #Probably the worst example program provided.
  8.  
  9. #There are two basic modes of operation, determined by the
  10. #value of “use_marquee”. This variable ca be set with the
  11. #“Set variables” dialog -- if 
  12. #    use_marquee=0
  13. #then a long plain-text message can be displayed; if
  14. #    use_marquee=1
  15. #then giant capitals will be used for the display.
  16. #The giant messages for the marquee take around 5 minutes
  17. #to generate, so you have the option of saving messages to
  18. #a file and reading it back in. Set
  19. #    write_message=1
  20. #and the generated giant message will be written to disk, in
  21. #a file with the same name as the message, in your “hAWK programs”
  22. #folder. Set
  23. #    read_message=1
  24. #and the message will be read from disk, rather than regenerated.
  25. #In both cases the message and file name is determined by the
  26. #line just after the comment #MARQUEE MESSAGE below.
  27.  
  28. #Modes of behaviour:
  29. #use_marquee=0    ;endless loop, displays the message after “#long text message”
  30. #use_marquee=1    ;
  31. #    if write_message=1 and read_message=0 , writes the giant MARQUEE MESSAGE and exits
  32. #                        (this may take 5 or so minutes)
  33. #    if read_message=1 , reads the giant message from the file named by MARQUEE MESSAGE
  34. #                        and write_message is ignored ; loops endlessly
  35. #    if write_message=1 and read_message=0 , generates and displays the MARQUEE MESSAGE
  36. #                        and loops endlessly (takes about five minutes to get going)
  37. #Written and restored giant messages should be no more than 31 characters in length,
  38. #and composed of uppercase, numbers, and !.,-? only.
  39. #Change the text message to your liking. If a long message with use_marquee=0
  40. #folds to the second line, reduce fieldWidth a bit to compensate.
  41.  
  42. #Oddity note - your screen-saver may still work
  43. #even while hAWK is running.
  44.  
  45. # User’s Manual references:
  46. # «hAWK User’s Manual» «F   Running hAWK programs»
  47. # «hAWK User’s Manual» «L  5   Regular expressions»
  48. # «hAWK User’s Manual» «M  5   Built-in string and file functions»
  49. # «hAWK User’s Manual» «K  4   Built-in variables»
  50. # «hAWK User’s Manual» «K  8   Arrays»
  51. # «hAWK User’s Manual» «N   User-defined functions»
  52. # «hAWK User’s Manual» «P  3   The getline function»
  53. # «hAWK User’s Manual» «O  3   Output into files»
  54. # «hAWK User’s Manual» «Q   The hAWK function»
  55.  
  56.  
  57. BEGIN    {    fieldWidth = 45 #number of text characters in plain message at once
  58.             marqueeWidth = 7 #number of giant marquee characters at once
  59.             if (use_marquee+0 == 0)
  60.                 {
  61.                 #long text message
  62.                 message = "Extremely sophisticated algorithm under test -- please do not touch."
  63.                 ScrollMessage(message);
  64.                 }
  65.             else
  66.                 {
  67.                 #MARQUEE MESSAGE
  68.                 #Canned messages: "OUT TO LUNCH", "PLEASE DO NOT TOUCH!!"
  69.                 message = "PLEASE DO NOT TOUCH!!";#use uppercase, numbers, and ?!.,- only
  70.                 if (read_message+0 != 0)
  71.                     {
  72.                     msgfile = STDPATH "Drag_on Modules:hAWK programs:" message
  73.                     while (getline < msgfile > 0)
  74.                         {
  75.                         s[++z] = $0
  76.                         for (q = 1; q <= 4; ++q)
  77.                             {
  78.                             if (getline < msgfile > 0)
  79.                                 s[z] = s[z] "\n" $0
  80.                             }
  81.                         }
  82.                     close(msgfile)
  83.                     $0 = ""
  84.                     }
  85.                 ScrollMarqueeMessage();
  86.                 }
  87.         }
  88.  
  89. function ScrollMessage(msg,    m,i, totalLen, three_m, shifter)
  90.     {
  91.     m = length(msg)
  92.     for (i = 1; i < fieldWidth; ++i)
  93.         field_blanks = field_blanks " "
  94.     three_m = 3*m
  95.     for (i = 1; i <= three_m; ++i)
  96.         three_m_blanks = three_m_blanks " "
  97.     msg = three_m_blanks field_blanks msg
  98.     totalLen = m + fieldWidth + three_m
  99.     while (1)
  100.         {
  101.         shifter = int(rand()*m) + 1
  102.         for (i = 1 + (three_m - 3*shifter); i <= totalLen; ++i)
  103.             {
  104.             progress_string = substr(msg, i+ 3*shifter, fieldWidth)\
  105.             "\n" substr(msg, i+ 2*shifter, fieldWidth)\
  106.             "\n" substr(msg, i+shifter, fieldWidth)\
  107.             "\n" substr(msg, i, fieldWidth);
  108.             progress(progress_string)
  109.             wait()
  110.             }
  111.         wait()
  112.         progress(time())
  113.         for (i = 1; i <= 50; ++i)
  114.             wait()
  115.         }
  116.     }
  117.  
  118. function wait(        i)
  119.     {
  120.     for (i = 1; i <= 20; ++i)
  121.         ;
  122.     }
  123.  
  124. function ScrollMarqueeMessage(    m,i,totalLen,totalStrings)
  125.     {
  126.     if (read_message+0 == 0 || z+0 == 0)
  127.         {
  128.         InitMarquee();
  129.         m = length(message)
  130.         if (m == 0)
  131.             {
  132.             message = "BYE FOR NOW"
  133.             m = length(message)
  134.             }
  135.         for (i = 1; i <= marqueeWidth; ++i)
  136.             field_blanks = field_blanks " "
  137.         if (write_message+0 != 0)
  138.             msgfile = STDPATH "Drag_on Modules:hAWK programs:" message
  139.         message = field_blanks message
  140.         totalLen = m + marqueeWidth
  141.         for (i = 1; i <= totalLen; ++i)
  142.             {
  143.             textStr = substr(message, i, marqueeWidth+1)
  144.             for (bitOff = 0; bitOff < 5; ++bitOff)
  145.                 {
  146.                 StringToMarquee()
  147.                 PrintMarqueeToString(5*(i-1)+bitOff+1)
  148.                 #progress(marquee_string)
  149.                 }
  150.             }
  151.         totalStrings = 5*totalLen
  152.         if (write_message+0 != 0)
  153.             {
  154.             for (i = 1; i <= totalStrings; ++i)
  155.                 print s[i] > msgfile
  156.             exit  #optional
  157.             }
  158.         }
  159.     else
  160.         totalStrings = z;
  161.     while (1)
  162.         {
  163.         for (i = 1; i <= totalStrings; ++i)
  164.             {
  165.             progress(s[i])
  166.             wait()
  167.             }
  168.         wait()
  169.         progress(time())
  170.         for (i = 1; i <= 20; ++i)
  171.             wait()
  172.         }
  173.     }
  174.  
  175.  
  176. function StringToMarquee(     char, i, len)
  177.     {
  178.     InitMarqueeArray()
  179.     len = length(textStr)
  180.     if (len > marqueeWidth+1)
  181.         len = marqueeWidth+1;
  182.     for (i = 1; i <= len; ++i)
  183.         {
  184.         char = substr(textStr, i, 1)
  185.         SetMarqueeLetter(i, char)
  186.         }
  187.     }
  188.  
  189. function InitMarqueeArray(    i,j, true_length)
  190.     {
  191.     true_length = (marqueeWidth+1)*5
  192.     for (i = -5; i <= true_length; ++i)
  193.         {
  194.         for (j = 1; j <= 5; ++j)
  195.             arr[j,i] = " ";#<Option><space>
  196.         }
  197.     }
  198.  
  199. #arr is 2-D array holding row,column (1 up) of the entire displayed
  200. #message; each giant character is 5 by 5 real Chicago characters
  201. #with the darker characters defined by the marquee array below.
  202. #charPos is position of marquee letter (1 up)
  203. #bitOffset is offset of character in characters (0-4) to the LEFT (-ve interpretation
  204. #of its positive value)
  205. #char is the marquee character.
  206. #The digit 1 is used as the printing character - this can be changed
  207. #to anything else that’s the same size
  208. function SetMarqueeLetter(charPos, char,    offset, n, i)
  209.     {
  210.     if (char == " " || char == "\t")
  211.         return;
  212.     n = split(marquee[char], coords);
  213.     offset = 5*(charPos-1) - bitOff
  214.     for (i = 1; i < n; i += 2)
  215.         arr[coords[i], coords[i+1]+offset] = "1";
  216.     }
  217.  
  218. function PrintMarqueeToString(ind,        i,j, true_length)
  219.     {
  220.     s[ind] = ""
  221.     true_length = marqueeWidth*5
  222.     for (j = 1; j <= 5; ++j)
  223.         {
  224.         for (i = 1; i <= true_length; ++i)
  225.             {
  226.             s[ind] = s[ind] arr[j,i]
  227.             }
  228.         if (j < 5)
  229.             s[ind] = s[ind] "\n"
  230.         }
  231.     }
  232.  
  233. #MarqueeFont: pairs of row/column coordinates, each 1:5
  234. #This took forever to do - never again.
  235. function InitMarquee()
  236.     {
  237.     marquee["A"] = "1 3 2 2 2 4 3 1 3 2 3 3 3 4 3 5 4 1 4 5 5 1 5 5"
  238.     marquee["B"] = "1 1 1 2 1 3 1 4 2 1 2 5 3 1 3 2 3 3 3 4 4 1 4 5 5 1 5 2 5 3 5 4"
  239.     marquee["C"] = "1 2 1 3 1 4 2 1 3 1 4 1 5 2 5 3 5 4"
  240.     marquee["D"] = "1 1 1 2 1 3 1 4 2 1 2 5 3 1 3 5 4 1 4 5 5 1 5 2 5 3 5 4"
  241.     marquee["E"] = "1 1 1 2 1 3 1 4 1 5 2 1 3 1 3 2 3 3 3 4 4 1 5 1 5 2 5 3 5 4 5 5"
  242.     marquee["F"] = "1 1 1 2 1 3 1 4 1 5 2 1 3 1 3 2 4 1 5 1"
  243.     marquee["G"] = "1 2 1 3 1 4 1 5 2 1 3 1 3 4 4 5 4 1 4 5 5 2 5 3 5 4 5 5"
  244.     marquee["H"] = "1 1 1 5 2 1 2 5 3 1 3 2 3 3 3 4 3 5 4 1 4 5 5 1 5 5"
  245.     marquee["I"] = "1 2 1 3 1 4 2 3 3 3 4 3 5 2 5 3 5 4"
  246.     marquee["J"] = "1 1 1 2 1 3 1 4 1 5 2 3 3 1 3 3 4 1 4 3 5 2"
  247.     marquee["K"] = "1 1 1 4 2 1 2 3 3 1 3 2 3 3 4 1 4 4 5 1 5 5"
  248.     marquee["L"] = "1 1 2 1 3 1 4 1 5 1 5 2 5 3 5 4"
  249.     marquee["M"] = "1 1 1 5 2 1 2 2 2 4 2 5 3 1 3 3 3 5 4 1 4 5 5 1 5 5"
  250.     marquee["N"] = "1 1 1 5 2 1 2 2 2 5 3 1 3 3 3 5 4 1 4 4 5 5 5 1 5 5"
  251.     marquee["O"] = "1 2 1 3 1 4 2 1 2 5 3 1 3 5 4 1 4 5 5 2 5 3 5 4"
  252.     marquee["P"] = "1 1 1 2 1 3 1 4 2 1 2 5 3 1 3 2 3 3 3 4 4 1 5 1"
  253.     marquee["Q"] = "1 2 1 3 1 4 2 1 2 5 3 1 3 5 4 1 4 3 3 5 5 2 5 3 5 4"
  254.     marquee["R"] = "1 1 1 2 1 3 1 4 2 1 2 5 3 1 3 2 3 3 3 4 4 1 4 4 5 1 5 5"
  255.     marquee["S"] = "1 2 1 3 1 4 2 1 3 2 3 3 3 4 4 5 5 1 5 2 5 3 5 4"
  256.     marquee["T"] = "1 1 1 2 1 3 1 4 1 5 2 3 3 3 4 3 5 3"
  257.     marquee["U"] = "1 1 1 5 2 1 2 5 3 1 3 5 4 1 4 5 5 2 5 3 5 4"
  258.     marquee["V"] = "1 1 1 5 2 1 2 4 3 1 3 3 4 1 4 2 5 1"
  259.     marquee["W"] = "1 1 1 5 2 1 2 5 3 1 3 3 3 5 4 1 4 2 4 4 4 5 5 1 5 5"
  260.     marquee["X"] = "1 1 1 5 2 2 2 4 3 3 4 2 4 4 5 1 5 5"
  261.     marquee["Y"] = "1 1 1 5 2 2 2 4 3 3 4 3 5 3"
  262.     marquee["Z"] = "1 1 1 2 1 3 1 4 1 5 2 4 3 3 4 2 5 1 5 2 5 3 5 4 5 5"
  263.     marquee["0"] = "1 3 1 4 2 2 2 5 3 2 3 5 4 2 4 5 5 2 5 3"
  264.     marquee["1"] = "1 3 2 2 2 3 3 3 4 3 5 2 5 3 5 4"
  265.     marquee["2"] = "1 2 1 3 1 4 2 5 3 3 3 4 4 2 4 5 5 2 5 3 5 4 5 5"
  266.     marquee["3"] = "1 2 1 3 1 4 2 5 3 3 3 4 4 5 5 2 5 3 5 4"
  267.     marquee["4"] = "1 2 1 4 2 2 2 4 3 2 3 3 3 4 3 5 4 4 5 4"
  268.     marquee["5"] = "1 2 1 3 1 4 1 5 2 2 3 2 3 3 3 4 4 5 5 2 5 3 5 4"
  269.     marquee["6"] = "1 4 1 5 2 3 3 2 3 4 3 5 4 3 4 5 5 4 5 5"
  270.     marquee["7"] = "1 2 1 3 1 4 1 5 2 4 3 3 4 2 5 2"
  271.     marquee["8"] = "1 3 1 4 2 2 2 5 3 3 3 4 4 2 4 5 5 2 5 3"
  272.     marquee["9"] = "1 3 1 4 2 2 2 5 3 3 3 4 3 5 4 5 5 4 5 5"
  273.     marquee["."] = "4 2 4 3 5 2 5 3"
  274.     marquee["?"] = "1 1 1 2 1 3 2 4 3 2 3 3 5 2"
  275.     marquee["!"] = "1 2 1 3 2 2 2 3 3 2 3 3 5 2 5 3"
  276.     marquee[","] = "3 2 3 3 4 3 5 2"
  277.     marquee["-"] = "3 2 3 3 3 4"
  278.     }
  279.